<template>
    <s-table  ref="tableRef"  :data="loadData"  :scroll="{ x: 1200, }"  :columns="columns" :pagination="false" class="mb-2">
        <template #bodyCell="{ column, record, index }">
            <template v-if="column.key === 'index'">
                {{ index + 1 }}
            </template>
        </template>
    </s-table>
</template>

<script setup name="invitebid">
import api from '@/api/pm/cost/index'
const props = defineProps({
    proId: {
        type: String,
    },
})
const { proId } = toRefs(props)

const columns = [
    {
        title: '序号',
        dataIndex: 'index',
        key: 'index',
        width: 70,
    },

    {
        title: '预算单编号',
        dataIndex: 'code',
        key: 'code',
        width: 100,
        align: 'center'
    },
    {
        title: '预算单名称',
        dataIndex: 'name',
        key: 'name',    width: 100,
        align: 'center'
    },

    {
        title: '项目名称',
        dataIndex: 'proName',
        key: 'proName',    width: 100,
        align: 'center'

    },
   
    {
        title: '合作单位',
        dataIndex: 'cooperativeUnits',
        key: 'cooperativeUnits',    width: 100,
        align: 'center'

    },
    {
        title: '成本总额',
        dataIndex: 'amount',
        key: 'amount',    width: 100,
        align: 'center'
    },
    {
        title: '申请人',
        dataIndex: 'appUser',
        key: 'appUser',    width: 100,
        align: 'center'
    },
    {
        title: '申请部门',
        dataIndex: 'appDepartment',
        key: 'appDepartment',    width: 100,
        align: 'center'
    },
    {
        title: '审核状态',
        dataIndex: 'status',
        key: 'status',    width: 100,
        align: 'center'
    },
    {
        title: '申请日期',
        dataIndex: 'createTime',
        key: 'createTime',  
          width: 160,
        align: 'center'
    },
]
const tableRef = ref()
const loadData = (parameter) => {
    const searchFormState = ref({
        proId: proId
    })
    searchFormState.value.current = parameter.current
    searchFormState.value.size = parameter.size
    return api.page(searchFormState.value).then((res) => {
        return res
    })
}



watch(
    () => props.proId,
    (newVal, oldVal) => {
        if (newVal) {
            nextTick(() => {
                tableRef.value.refresh(true)
            })
        }
    },
    { deep: true, immediate: true }
)


</script>
